import React, { Component } from 'react'
import {connect} from 'react-redux'
import store from '../redux/store.js'

class Detail extends Component {
    constructor(props) {
        super(props);
        let item = props.planlist.planlist.filter(data=>data.id==props.match.params.id)
    	this.state = {
    		plan : item[0]
    	}
    }
    render() {
    	let {plan} = this.state;
        return (
            <div style={{padding: '20px'}}>
                <h3>计划详情</h3>
                <p>id： {plan.id}</p>
                <p>标题： {plan.title}</p>
                <p>内容： {plan.content}</p>
            </div>

        )
    }
}
const mapStateToProps = function(store) {
  return {
    planlist: store.planlist
  };
};
// 连接 tore 和组件
export default connect(mapStateToProps)(Detail);